<!DOCTYPE html>
<html>
  <head>
  	<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>湛江潜校</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="<c:url value="/bootstrap/css/bootstrap.min.css"/>"/>
    <!-- Font Awesome -->
    <link rel="stylesheet" href="<c:url value="/dist/css/font-awesome.min.css"/>"/>
    <!-- Ionicons -->
    <link rel="stylesheet" href="<c:url value="/dist/css/ionicons.min.css"/>"/>
    <!-- Theme style -->
    <link rel="stylesheet" href="<c:url value="/dist/css/AdminLTE.min.css"/>"/>
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="<c:url value="/dist/css/skins/_all-skins.min.css"/>"/>
    <!-- iCheck -->
    <link rel="stylesheet" href="<c:url value="/plugins/iCheck/flat/blue.css"/>"/>
    <!-- Morris chart -->
    <link rel="stylesheet" href="<c:url value="/plugins/morris/morris.css"/>"/>
    <!-- jvectormap -->
    <link rel="stylesheet" href="<c:url value="/plugins/jvectormap/jquery-jvectormap-1.2.2.css"/>"/>
    <!-- Date Picker -->
    <link rel="stylesheet" href="<c:url value="/plugins/datepicker/datepicker3.css"/>"/>
    <!-- Daterange picker -->
    <link rel="stylesheet" href="<c:url value="/plugins/daterangepicker/daterangepicker-bs3.css"/>"/>
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="<c:url value="/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"/>"/>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="<c:url value="/dist/js/html5shiv.min.js"/>"></script>
        <script src="<c:url value="/dist/js/respond.min.js"/>"></script>
    <![endif]-->
  </head>
  <body class="hold-transition skin-blue sidebar-mini">
    <div class="wrapper">

      <header class="main-header">
        <!-- Logo -->
        <a href="../index.html" class="logo">
          <!-- mini logo for sidebar mini 50x50 pixels -->
          <span class="logo-mini"><b>ZJ</b>QX</span>
          <!-- logo for regular state and mobile devices -->
          <span class="logo-lg"><b>湛江</b>潜校</span>
        </a>
        <!-- Header Navbar: style can be found in header.less -->
        <nav class="navbar navbar-static-top" role="navigation">
          <!-- Sidebar toggle button-->
          <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
          </a>
        </nav>
      </header>
      <!-- Left side column. contains the logo and sidebar -->
      <aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
          <section class="sidebar">
          <!-- /.search form -->
          <!-- sidebar menu: : style can be found in sidebar.less -->
          <ul class="sidebar-menu">
            <li class="header">主菜单</li>
			<!-- 药房管理员 -->
			<c:if test="${permission==3}">
			<li class="treeview">
              <a href="#">
                <i class="fa fa-files-o"></i>
                <span>药品管理</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="${ctp }/drugManager/addDrug"><i class="fa fa-circle-o">新建药品</i></a></li>
                <li><a href="${ctp }/drugManager/getDrugList"><i class="fa fa-circle-o">药品列表</i></a></li>
                <li><a href="../medicine/inventoryMedicineNotice.html"><i class="fa fa-circle-o">库存警戒线药品</i></a></li>
                <li><a href="../medicine/expiredMedicine.html"><i class="fa fa-circle-o">药品报损表</i></a></li>
                <li><a href="../medicine/deliverMedicine.html"><i class="fa fa-circle-o">物资发放</i></a></li>
                <li><a href="../medicine/deliverList.html"><i class="fa fa-circle-o">物资发放列表</i></a></li>
              </ul>
            </li>
			<li class="treeview">
              <a href="#">
                <i class="fa fa-files-o"></i>
                <span> 缴费管理</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="../pay/registeredList.html"><i class="fa fa-circle-o">挂号</i></a></li>
                <li><a href="../pay/payList.html"><i class="fa fa-circle-o">处方缴费</i></a></li>
                <li><a href="../pay/refundList.html"><i class="fa fa-circle-o">处方退费</i></a></li>
                <li><a href="../pay/registeredStatistics.html"><i class="fa fa-circle-o">挂号统计</i></a></li>
                <li><a href="../pay/paymentStatistics.html"><i class="fa fa-circle-o">缴费统计</i></a></li>
                <li><a href="../pay/refundStatistics.html"><i class="fa fa-circle-o">退费统计</i></a></li>
              </ul>
            </li>
            <li class="treeview">
              <a href="#">
                <i class="fa fa-dashboard"></i> 
                <span>医疗卡管理</span> 
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="${ctp }/drugManager/addPatient"><i class="fa fa-circle-o"></i>新办医疗卡</a></li>
                <li><a href="${ctp }/drugManager/getPatientList"><i class="fa fa-circle-o"></i>医疗卡列表</a></li>
                <li><a href="../card/cardSearch.html"><i class="fa fa-circle-o"></i>医疗卡查询</a></li>
              </ul>
            </li>
			</c:if>
			<!-- 医生 -->
			<c:if test="${permission==2}">
            <li class="treeview">
              <a href="#">
                <i class="fa fa-files-o"></i>
                <span>处方管理</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href=""><i class="fa fa-circle-o"></i>查看处方</a></li>
                <li><a href="${ctp }/doctor/addRecipe"><i class="fa fa-circle-o"></i>添加处方</a></li>
                <li><a href="${ctp }/doctor/getRecipeList"><i class="fa fa-circle-o"></i>处方列表</a></li>
              </ul>
            </li>
			</c:if>
			<!-- 导医 -->
			<c:if test="${permission==4}">
			 <li class="treeview">
              <a href="#">
                <i class="fa fa-files-o"></i>
                <span>绩效统计</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="../finance/personalWorkload.html"><i class="fa fa-circle-o">个人工作量统计</i></a></li>
                <li><a href="../finance/performance.html"><i class="fa fa-circle-o">绩效统计</i></a></li>
              </ul>
            </li>
			<li><a href="../prescription/showPrescription.html"><i class="fa fa-circle-o"></i>查看处方</a></li>
			</c:if>
			
			
            
			<!-- 超级管理员 -->
			<c:if test="${permission==5 }">
			<li class="treeview">
              <a href="#">
                <i class="fa fa-files-o"></i>
                <span> 用户管理</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="${ctp }/superUser/addUser"><i class="fa fa-circle-o">新增用户</i></a></li>
                <li><a href="${ctp }/superUser/getUsers"><i class="fa fa-circle-o">用户列表</i></a></li>
              </ul>
            </li>
            <li class="treeview">
              <a href="#">
                <i class="fa fa-files-o"></i>
                <span> 治疗管理</span>
                <i class="fa fa-angle-left pull-right"></i>
              </a>
              <ul class="treeview-menu">
                <li><a href="${ctp }/superUser/addCureList"><i class="fa fa-circle-o">新建治疗项目</i></a></li>
                <li><a href="../project/addPhysicalExamination.html"><i class="fa fa-circle-o">新建体格诊断</i></a></li>
                <li><a href="${ctp }/superUser/getCureList"><i class="fa fa-circle-o">治疗项目列表</i></a></li>
                <li><a href="../project/physicalExaminationList.html"><i class="fa fa-circle-o">体格诊断列表</i></a></li>
              </ul>
            </li>
			</c:if>

          </ul>
        </section>
        <!-- /.sidebar -->
      </aside>


       <!-- 主体部分 START -->

      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            新建治疗项目
          </h1>
        </section>

        <section class="content">
        <div class="nav-tabs-custom">
                <ul class="nav nav-tabs">
                  <li class="active"><a aria-expanded="false" href="#tab_1" data-toggle="tab">新建一级治疗项目</a></li>
                  <li><a aria-expanded="false" href="#tab_2" data-toggle="tab">新建二级治疗项目</a></li>
                  <li><a aria-expanded="true" href="#tab_3" data-toggle="tab">新建三级治疗项目</a></li>
                </ul>
                <div class="tab-content"  style="height:600px;">
                  <div class="tab-pane   active" id="tab_1" style="height:500px;">
                      <div class="box box-primary">
                          <div class="box-header with-border">
                            <h3 class="box-title">新建一级治疗项目</h3>
                          </div><!-- /.box-header -->
                          <!-- form start -->
                          <form:form modelAttribute="cureList" action="${ctp }/superUser/addCureList" id="form1" role="form">
                            <div class="box-body">
                              <div class="form-group">
                                <label for="">治疗项目名称</label><span class="notice" style="color:red;"></span>
                                <form:input path="curename" class="form-control" id="name1" type="text"/>
                                <form:hidden path="curelevel" value="1"/>
                               <form:hidden path="lastcureid" value="-1"/>
                                
                              </div>
                              <div class="form-group">
                                <label for="">治疗项目价格</label><span class="notice" style="color:red;"></span>
                                <form:input path="price" class="form-control" id="price1" type="number"/>
                              </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                              <button id="submit1" class="btn btn-primary">新建</button>
                            </div>
                          </form:form>
                        </div>   
                  </div><!-- /.tab-pane -->
                  <div class="tab-pane " id="tab_2"  style="height:500px;">
                        <div class="box box-primary">
                          <div class="box-header with-border">
                            <h3 class="box-title">新建二级治疗项目</h3>
                          </div><!-- /.box-header -->
                          <!-- form start -->
                          <form:form modelAttribute="cureList" id="form2" role="form">
                            <div class="box-body">
                              <div class="form-group">
                                <label for="">一级治疗项目</label>
                                <div style="">
                                <form:select path="lastcureid" class="form-control" style="width:200px;display:inline-block;">
                                  <c:forEach items="${ cureListsForLevelOne}" var="lastCure">
                                  	<form:option value="${lastCure.cureid }"><c:out value="${lastCure.curename }"></c:out></form:option>
                                  </c:forEach>
                                </form:select>
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="">治疗项目名称</label><span class="notice" style="color:red;"></span>
                                <form:input path="curename" class="form-control" id="name2" type="text"/>
                                <form:hidden path="curelevel" value="2"/>
                                
                                
                              </div>
                              <div class="form-group">
                                <label for="">治疗项目价格</label><span class="notice" style="color:red;"></span>
                                <form:input path="price" class="form-control" id="price2" type="number"/>
                              </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                              <button id="submit2" class="btn btn-primary">新建</button>
                            </div>
                          </form:form>
                        </div>   
                  </div><!-- /.tab-pane -->
                  <div class="tab-pane" id="tab_3"  style="height:500px;">
                        <div class="box box-primary">
                          <div class="box-header with-border">
                            <h3 class="box-title">新建三级治疗项目</h3>
                          </div><!-- /.box-header -->
                          <!-- form start -->
                          <form:form modelAttribute="cureList" id="form3" role="form">
                            <div class="box-body">
                              <div class="form-group">
                                <label for="">一级治疗项目</label>
                                <div style="">
                                <!-- 不要提交 提交会报错  -->
                                <select  id="firstType" class="form-control" style="width:200px;display:inline-block;">
                    
                                  <c:forEach items="${cureListsForLevelOne}" var="lastCure">
                                  	<option value="${lastCure.cureid }"><c:out value="${lastCure.curename }"></c:out></option>
                                  </c:forEach>
                                </select>
                                </div>
                              </div>
                              <div class="form-group">
                                <label for="">二级治疗项目</label>
                                <div style="">
                                <select class="form-control" id="secondType" style="width:200px;display:inline-block;">
                                </select>
                                </div>
                                <form:input path="lastcureid" class="form-control" id="thirdLastCureId" type="hidden" value=""/>
                                <form:hidden path="curelevel" value="3"/>
                              </div>
                              <div class="form-group">
                                <label for="">治疗项目名称</label><span class="notice" style="color:red;"></span>
                                <form:input path="curename" class="form-control" id="name3" type="text" />
                              </div>
                              <div class="form-group">
                                <label for="">治疗项目价格</label><span class="notice" style="color:red;"></span>
                                <form:input path="price" class="form-control" id="price3" type="number" />
                              </div>
                            </div><!-- /.box-body -->

                            <div class="box-footer">
                              <button id="submit3" class="btn btn-primary">新建</button>
                            </div>
                          </form:form>
                        </div>   
                  </div><!-- /.tab-pane -->
                </div><!-- /.tab-content -->
              </div>

        </section><!-- /.Left col -->

      </div>

      <!-- 主体部分 END -->



      <footer class="main-footer">
        <div class="pull-right hidden-xs">
          <b>Version</b> 1.0.0
        </div>
        <strong>Copyright &copy; 2015-2015 湛江潜校 .</strong> All rights reserved.
      </footer>

      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->

    <!-- jQuery 2.1.4 -->
    <script src="<c:url value="/plugins/jQuery/jQuery-2.1.4.min.js"/>"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="<c:url value="/dist/js/jquery-ui.min.js"/>"></script>
    <!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
    <script src="<c:url value="/dist/js/hospital.js"/>"></script>
    <script>
      $.widget.bridge('uibutton', $.ui.button);
      
		//address:接口地址 selectId:要改变列表的ID
		$.changeTypeList = function(address, selectId){
			//获取选中的option的value
			lastcureid = $("#firstType  option:selected").val();
		    $.typeListAjax(address, lastcureid, selectId);
		}
		//进行查询，查询成功则进行操作
		$.typeListAjax = function(address, lastcureid, selectId){
		  $.ajax({
		            type: "post",
			        url: address+lastcureid,
			        dataType: "json",
			        success: function (data) {
			        		console.log(data);
			        		typeList = data;
			        		console.log(typeList);
			        		$(selectId).find("option").remove();
			        		for(var i = 0;i<(typeList.length-1);i++){
			        		$("<option></option>").val(typeList[i]['cureid']).text(typeList[i]['curename']).appendTo(selectId); 
			        		}
			        		thelastcureid = $("#secondType  option:selected").val();
			    			$('#thirdLastCureId').val(thelastcureid);
			        },
			        error: function (XMLHttpRequest, textStatus, errorThrown) {
			                console.log(errorThrown);
			                alert('获取列表信息失败，请重新尝试。');
			        }
			});
		}
	      STATUS={};
	      STATUS.name1 = false;
	      STATUS.price1 = false;
	      STATUS.name2 = false;
	      STATUS.price2 = false;
	      STATUS.name3 = false;
	      STATUS.price3 = false;
		
		
	    $(document).ready(
	    		//第一次访问时加载第一个一级类型的二级类型
	    		$.changeTypeList('${ctp}/superUser/forAjax?lastCureId=','#secondType'),
	    		$('#firstType').bind("change",function() {
	    		        $.changeTypeList('${ctp}/superUser/forAjax?lastCureId=','#secondType');
	    		    }),
	    		$('#secondType').bind("change",function() {
	    			thelastcureid = $("#secondType  option:selected").val();
	    			$('#thirdLastCureId').val(thelastcureid);
	    		}
	    		),
	    		$('#name1').blur(function(){
	        		$.isNotNull('name1','#name1','请输入治疗项目名称');
	            }),
	            $('#price1').blur(function(){
	            	$.isNotNull('price1','#price1','请输入治疗项目价格');
	            	$.isValid('price1','#price1',regFloat,'请输入正确的价格');
	            }),
	            $('#name2').blur(function(){
	        		$.isNotNull('name2','#name2','请输入治疗项目名称');
	            }),
	            $('#price2').blur(function(){
	            	$.isNotNull('price2','#price2','请输入治疗项目价格');
	            	$.isValid('price2','#price2',regFloat,'请输入正确的价格');
	            }),
	            $('#name3').blur(function(){
	        		$.isNotNull('name3','#name3','请输入治疗项目名称');
	            }),
	            $('#price3').blur(function(){
	            	$.isNotNull('price3','#price3','请输入治疗项目价格');
	            	$.isValid('price3','#price3',regFloat,'请输入正确的价格');
	            }),
	            $('#submit1').click(function(){
	          		if(STATUS.name1&&STATUS.price1){
	          			$('#form1').submit();
	          		}else{
	          			alert('有不合法输入，请重新检查。');
	          			return false;
	          		}
	          	}),
	          	$('#submit2').click(function(){
	          		if(STATUS.name2&&STATUS.price2){
	          			$('#form2').submit();
	          		}else{
	          			alert('有不合法输入，请重新检查。');
	          			return false;
	          		}
	          	}),
	          	$('#submit3').click(function(){
	          		if(STATUS.name3&&STATUS.price3){
	          			$('#form3').submit();
	          		}else{
	          			alert('有不合法输入，请重新检查。');
	          			return false;
	          		}
	          	})
	            
	    		);
    </script>
    <!-- Bootstrap 3.3.5 -->
    <script src="<c:url value="/bootstrap/js/bootstrap.min.js"/>"></script>
    <!-- Morris.js charts -->
    <script src="<c:url value="/dist/js/raphael-min.js"/>"></script>
    <script src="<c:url value="/plugins/morris/morris.min.js"/>"></script>
    <!-- Sparkline -->
    <script src="<c:url value="/plugins/sparkline/jquery.sparkline.min.js"/>"></script>
    <!-- jvectormap -->
    <script src="<c:url value="/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"/>"></script>
    <script src="<c:url value="/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"/>"></script>
    <!-- jQuery Knob Chart -->
    <script src="<c:url value="/plugins/knob/jquery.knob.js"/>"></script>
    <!-- daterangepicker -->
    <script src="<c:url value="/dist/js/moment.min.js"/>"></script>
    <script src="<c:url value="/plugins/daterangepicker/daterangepicker.js"/>"></script>
    <!-- datepicker -->
    <script src="<c:url value="/plugins/datepicker/bootstrap-datepicker.js"/>"></script>
    <!-- Bootstrap WYSIHTML5 -->
    <script src="<c:url value="/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"/>"></script>
    <!-- Slimscroll -->
    <script src="<c:url value="/plugins/slimScroll/jquery.slimscroll.min.js"/>"></script>
    <!-- FastClick -->
    <script src="<c:url value="/plugins/fastclick/fastclick.min.js"/>"></script>
    <!-- AdminLTE App -->
    <script src="<c:url value="/dist/js/app.min.js"/>"></script>
    <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
    <script src="<c:url value="/dist/js/pages/dashboard.js"/>"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="<c:url value="/dist/js/demo.js"/>"></script>
  </body>
</html>
